package cn.softwin.dao.impl;

import cn.softwin.dao.LinkManDao;
import cn.softwin.pojo.LinkMan;
import cn.softwin.utils.JDBCpoolUtils;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

public class LinkManDaoImpl implements LinkManDao {


    // 操作数据库的dao
    private Connection con = null;
    private PreparedStatement pstat = null;

    @Override
    public Boolean addLinkMan(LinkMan linkMan) {


        try {
            con = JDBCpoolUtils.getConnection();
            String sql = "insert into cst_linkman (lkm_name,lkm_gender,lkm_phone,lkm_mobile,lkm_email,lkm_qq,lkm_position,lkm_memo) values(?,?,?,?,?,?,?,?)";
            pstat = con.prepareStatement(sql);
            pstat.setString(1, linkMan.getLkmName());
            pstat.setString(2, linkMan.getLkmGender());
            pstat.setString(3, linkMan.getLkmPhone());
            pstat.setString(4, linkMan.getLkmMoblie());
            pstat.setString(5, linkMan.getLkmEmail());
            pstat.setString(6, linkMan.getLkmQQ());
            pstat.setString(7, linkMan.getLkmPosition());
            pstat.setString(8, linkMan.getLkmMemo());
            int count = pstat.executeUpdate();
            if (count>0) {
                return true;
            }
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } finally {
            JDBCpoolUtils.close(pstat, con);
        }
        return false;
    }
}
